﻿using System.Reflection.Metadata.Ecma335;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Services;
using YamlDotNet.Core.Tokens;
using YAPACS.BusinessObjects.Managements.Exams;
using YAPACS.RisServer.Abstractions;
using YAPACS.RisServer.Services.ExtendCells;

namespace YAPACS.RisServer.Services
{
    public class CellFactoryService : DomainService, ICellFactoryService, ITransientDependency
    {

        /// <summary>
        /// 获取控件单元格对象
        /// </summary>
        /// <param name="key">对饮到数据元名称，也是reportExtend字段中的属性</param>
        /// <param name="tabIndex">tabIndex</param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public ControlCell NewControlCell(ExamDataElement dataElement, string key,double width,string tag,int tabIndex)
        {
            return new ControlCell(key,dataElement,width,tag,tabIndex); 
        }


        /// <summary>
        /// 跨行单元格
        /// </summary>
        /// <param name="text">单元格文本</param>
        /// <param name="width">单元格原始宽度</param>
        /// <param name="rowSpan">跨行数</param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public MultiRowCell NewMultiRowCell(string text, double width, int rowSpan,string textAlign)
        {
            return new MultiRowCell(text, width, rowSpan, textAlign);
        }


        /// <summary>
        /// 获取占位单元格对象
        /// </summary>
        /// <param name="width"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public PlaceholderCell NewPlaceholderCell(double width)
        {
            return new PlaceholderCell(width);
        }


        /// <summary>
        /// 行flex组件对象
        /// </summary>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public RowFlex NewRowFlex()
        {
            return new RowFlex();
        }


        /// <summary>
        /// 单行文本单元格
        /// </summary>
        /// <param name="text">文本</param>
        /// <param name="width">宽度</param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public TextCell NewTextCell(string text, double width,string textAlign)
        {
            return new TextCell(text, width, 1,textAlign);
        }


        /// <summary>
        /// 标题单元格
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public TitleCell NewTitleCell(string text)
        {
            return new TitleCell(text);
        }


        /// <summary>
        /// 字段文字单元格
        /// </summary>
        /// <param name="text"></param>
        /// <param name="width"></param>
        /// <param name="rowSpan"></param>
        /// <param name="textAlign"></param>
        /// <returns></returns>
        public FieldTextCell NewFieldTextCell(string text, double width, int rowSpan, string textAlign) {
            return new FieldTextCell(text,width,rowSpan,textAlign);
        }


        /// <summary>
        /// 字段控件单元格
        /// </summary>
        /// <param name="key"></param>
        /// <param name="examDataElement"></param>
        /// <param name="width"></param>
        /// <param name="tag"></param>
        /// <param name="tableIndex"></param>
        /// <returns></returns>
        public FieldControlCell NewFieldControlCell(string key, ExamDataElement examDataElement, double width, string tag, int tableIndex) {
            return new FieldControlCell(key,examDataElement,width,tag,tableIndex);
        }
    }
}
